dst_img->pitch[0] = (dst_img->type[0]->bits / 8);
dst_img->stride[0] = 0;
- src_img->data[0] = source_buf;
+ src_img->data[0] = source_buf;
src_img->type[0] = source_fmt->type[0];
src_img->pitch[0] = source_fmt->type[0]->bits / 8;
src_img->stride[0] = 0;
static int
-process_same_model2 (const Babl *babl,
- const char *source,
- char *destination,
- long n)
+process_to_n_component (const Babl *babl,
+ const char *source,
+ char *destination,
+ long n)
{
void *double_buf;
-
+#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+ int components = MAX(BABL (babl->fish.source)->format.model->components,
+ BABL (babl->fish.source)->format.components);
+ components = MAX(components, BABL (babl->fish.destination)->format.components);
+ components = MAX(components, BABL (babl->fish.destination)->model.components);
- double_buf = babl_malloc (sizeof (double) * n *
- MAX (BABL (babl->fish.source)->format.model->components,
- BABL (babl->fish.source)->format.components));
-#undef MAX
+ double_buf = babl_malloc (sizeof (double) * n * components);
+ memset (double_buf, 0,sizeof (double) * n * components);
- if (1)
{
- /* FIXME: should recursively invoke babl and look up an appropriate fish
- * for the conversion and multiply n by the number of components.
- */
ncomponent_convert_to_double (
(BablFormat *) BABL (babl->fish.source),
(char *) source,
n
);
}
- else
- {
- convert_to_double (
- (BablFormat *) BABL (babl->fish.source),
- (char *) source,
- double_buf,
- n
- );
- convert_from_double (
- (BablFormat *) BABL (babl->fish.destination),
- double_buf,
- (char *) destination,
- n
- );
- }
babl_free (double_buf);
return 0;
}
long n)
{
void *double_buf;
-
#define MAX(a, b) ((a) > (b) ? (a) : (b))
double_buf = babl_malloc (sizeof (double) * n *
BABL (babl->fish.source)->format.components));
#undef MAX
- if (
- (BABL (babl->fish.source)->format.components ==
+ if ((BABL (babl->fish.source)->format.components ==
BABL (babl->fish.destination)->format.components)
&& (BABL (babl->fish.source)->format.model->components !=
BABL (babl->fish.source)->format.components))
{
- /* FIXME: should recursively invoke babl and look up an appropriate fish
- * for the conversion and multiply n by the number of components.
- */
ncomponent_convert_to_double (
(BablFormat *) BABL (babl->fish.source),
(char *) source,
if (babl_format_is_format_n (BABL (babl->fish.destination)))
{
- return process_same_model2 (babl, source, destination, n);
+ return process_to_n_component (babl, source, destination, n);
}
unsigned char out1[][1] = {{0}, {4}, {8} };
unsigned char out2[][2] = {{0,1}, {4,5}, {8,9} };
unsigned char out4[][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11} };
- //unsigned char out5[][5] = {{0,1,2,3,0}, {4,5,6,7,0},{8,9,10,11,0} };
+ unsigned char out5[][5] = {{0,1,2,3,0}, {4,5,6,7,0},{8,9,10,11,0} };
CHECK_CONV("RGBAu8 to n1'", unsigned char,
babl_format("R'G'B'A u8"),
babl_format_n (babl_type ("u8"), 1),
in, out1);
-
CHECK_CONV("RGBAu8 to n2'", unsigned char,
babl_format("R'G'B'A u8"),
babl_format_n (babl_type ("u8"), 2),
in, out2);
-
CHECK_CONV("RGBAu8 to n4'", unsigned char,
babl_format("R'G'B'A u8"),
babl_format_n (babl_type ("u8"), 4),
in, out4);
- /* XXX: uncomment this when it passes
CHECK_CONV("RGBAu8 to n5'", unsigned char,
babl_format("R'G'B'A u8"),
babl_format_n (babl_type ("u8"), 5),
in, out5);
- */
+ }
+ {
+ unsigned char in[][3] = {{0,1,2 },{4,5,6 },{8,9,10 }};
+ unsigned char out1[][1] = {{0}, {4}, {8} };
+ unsigned char out2[][2] = {{0,1}, {4,5}, {8,9} };
+ unsigned char out4[][4] = {{0,1,2,0}, {4,5,6,0}, {8,9,10,0} };
+ unsigned char out5[][5] = {{0,1,2,0,0}, {4,5,6,0,0},{8,9,10,0,0} };
+ unsigned char out6[][6] = {{0,1,2,0,0,0}, {4,5,6,0,0,0},{8,9,10,0,0,0} };
+
+ CHECK_CONV("RGBu8 to n1'", unsigned char,
+ babl_format("R'G'B' u8"),
+ babl_format_n (babl_type ("u8"), 1),
+ in, out1);
+
+
+ CHECK_CONV("RGBu8 to n2'", unsigned char,
+ babl_format("R'G'B' u8"),
+ babl_format_n (babl_type ("u8"), 2),
+ in, out2);
+
+
+ CHECK_CONV("RGBu8 to n4'", unsigned char,
+ babl_format("R'G'B' u8"),
+ babl_format_n (babl_type ("u8"), 4),
+ in, out4);
+
+ CHECK_CONV("RGBu8 to n5'", unsigned char,
+ babl_format("R'G'B' u8"),
+ babl_format_n (babl_type ("u8"), 5),
+ in, out5);
+
+ CHECK_CONV("RGBu8 to n6'", unsigned char,
+ babl_format("R'G'B' u8"),
+ babl_format_n (babl_type ("u8"), 6),
+ in, out6);
}
babl_exit ();